package com.tjetc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tjetc.entity.Tribe;
import com.tjetc.entity.UserActivity;
import com.tjetc.mapper.UserActivityMapper;
import com.tjetc.mapper.UserMapper;
import com.tjetc.service.IActivityService;
import com.tjetc.service.IUserActivityService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tjetc.service.IUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class UserActivityServiceImpl extends ServiceImpl<UserActivityMapper, UserActivity> implements IUserActivityService {
    @Resource
    private UserActivityMapper userActivityMapper;

    @Resource
    private IUserService userService;

    @Resource
    private IActivityService activityService;

    @Override
    public PageInfo<UserActivity> lists(Integer curPage, Integer pageSize, Integer userActivityId) {
        PageHelper.startPage(curPage, pageSize);
        List<UserActivity> list=userActivityMapper.lists(userActivityId);
        for (UserActivity userActivity : list) {
            userActivity.setUser(userService.getById(userActivity.getUserId()));
            userActivity.setActivity(activityService.getById(userActivity.getAid()));
        }

        return new PageInfo<>(list);
    }
}
